var t = require;
var e = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", { value: !0 });
var n = t("locales"),
    r = t("Sounds"),
    a = t("Platforms"),
    i = t("Scores"),
    s = t("ConfS"),
    c = require("./视频券"),
    l = t("Const"),
    u = (function() {
        function t() {}
        return (
            (t.init = function() {
                (this.剩余视频获取失败走分享次数 = s.DatasManager.视频获取失败走分享次数上限),
                (this.可点击 = !0),
                (this.s = new Array());
            }),
            (t.check = function(t) {
                for (var e = 0, o = t.getComponentsInChildren(c.default); e < o.length; e++) {
                    var n = o[e];
                    this.s.push(n), n.init();
                }
            }),
            (t.refresh = function() {
                for (var t = this.s.length; t--;) {
                    var e = this.s[t];
                    e.node && e.node.isValid ? e.refresh() : this.s.splice(t, 1);
                }
            }),
            (t.show = function(t, e, o) {
                console.log('show1')
                var c = this;
                if (this.可点击) {
                    console.log('show 可点击',this.可点击);
                    (this.可点击 = !1), a.default.delays.clear("延时处理onShow"), a.default.delays.clear("resumeMusic");
                    var u = "用户放弃";
                    cc.Canvas.instance.node.emit("禁止触摸");
                    var p = function(t) {
                        Adv_skd.default.instance.showVideo(()=>{
                            cc.Canvas.instance.node.emit("恢复触摸"),
                                t ?
                                (e && e(), c.onSuccess && c.onSuccess(), cc.Canvas.instance.node.emit("看视频成功")) :
                                (o && o(u), cc.Canvas.instance.node.emit("看视频失败")),
                                cc.Canvas.instance.node.emit("看视频完成", t),
                                (c.可点击 = !0),
                                a.default.delays.delay({
                                    time: 0.5,
                                    action: function() {
                                        r.Sounds.resumeMusic();
                                    },
                                    group: "resumeMusic"
                                });
                        },()=>{
                            t = !t
                            cc.Canvas.instance.node.emit("恢复触摸"),
                                t ?
                                (e && e(), c.onSuccess && c.onSuccess(), cc.Canvas.instance.node.emit("看视频成功")) :
                                (o && o(u), cc.Canvas.instance.node.emit("看视频失败")),
                                cc.Canvas.instance.node.emit("看视频完成", t),
                                (c.可点击 = !0),
                                a.default.delays.delay({
                                    time: 0.5,
                                    action: function() {
                                        r.Sounds.resumeMusic();
                                    },
                                    group: "resumeMusic"
                                });
                        })
                        console.log('show t',t);
                        
                    };
                    if (s.DatasManager.b){
                        console.log('show2');
                        p(!0);
                    } 
                    else {
                        console.log('show3');
                        if (a.default.userStorage.getItem("视频券") > 0){
                            console.log('show4');
                            return l.default.costMoney("视频券", 1, "看视频"), this.refresh(), void p(!0);
                        }
                        console.log('show5');
                        var f,
                            d = a.default.platformCtrl.rewardAdCtrl && a.default.platformCtrl.rewardAdCtrl.可显示(),
                            h = function() {
                                d ||
                                    (a.default.platformCtrl.rewardAdCtrl &&
                                        a.default.platformCtrl.rewardAdCtrl.show(t, null));
                            };
                        if (a.default.userStorage.看视频CDSec > 0) {
                            console.log('show6');
                            f = !1;
                            var y =
                                s.DatasManager.看视频CD -
                                (Math.ceil(new Date().getTime() / 1e3) - a.default.userStorage.看视频CDSec);
                            return a.default.platformCtrl.toast("当前观看视频过于频繁，请稍侯 " + y), void p(!1);
                        }
                        if (s.DatasManager.看视频上限 > 0) {
                            console.log('show7');
                            if (d && l.default.costMoney("看视频", 1, "看视频")){
                                console.log('show8');
                                this.checkWatchVideo && this.checkWatchVideo(), (f = !0);
                            }
                            else if ((f = this.走视频(!1))) {
                                console.log('show9');
                                if (a.default.userStorage.getItem("看视频") > 0){
                                    console.log('show10');
                                    a.default.platformCtrl.toast(
                                        n.locales.getText([
                                            s.DatasManager.视频已用尽CN,
                                            s.DatasManager.视频已用尽CN,
                                            s.DatasManager.视频已用尽EN
                                        ])
                                    );
                                }else {
                                    console.log('show11');
                                    var g =
                                        Math.round(new Date().getTime() / 1e3) -
                                        a.default.userStorage.lastRestoreWatchVideoSec,
                                        v = s.DatasManager.看视频恢复间隔 - g;
                                    a.default.platformCtrl.toast("当前观看次数不足，请稍侯 " + a.default.formatTime(v));
                                }
                                return h(), void p(!1);
                            }
                        } else{
                            console.log('show12');
                            f = this.走视频(d);
                            f
                                ?
                                (d ?
                                    r.Sounds.pauseMusic() :
                                    ((u = "视频耗尽"),
                                        a.default.platformCtrl.toast(
                                            n.locales.getText([
                                                s.DatasManager.视频已用尽CN,
                                                s.DatasManager.视频已用尽CN,
                                                s.DatasManager.视频已用尽EN
                                            ])
                                        )),
                                    a.default.platformCtrl.rewardAdCtrl ?
                                    (a.default.platformCtrl.dd_clickVideoBtn(
                                            t,
                                            a.default.platformCtrl.rewardAdCtrl.adId,
                                            a.default.platformCtrl.rewardAdCtrl.可显示()
                                        ),
                                        i.scores.add("看视频加分", s.DatasManager.每看一次视频得分),
                                        a.default.platformCtrl.rewardAdCtrl.show(t, function(e) {
                                            a.default.platformCtrl.dd_closeVideo(
                                                    t,
                                                    a.default.platformCtrl.rewardAdCtrl.adId,
                                                    e
                                                ),
                                                p(e),
                                                s.DatasManager.看视频CD > 0 &&
                                                a.default.userStorage.获取玩家今日总次数("rewardShow") >=
                                                s.DatasManager.每天看视频n次后开始CD &&
                                                ((a.default.userStorage.看视频CDSec = Math.ceil(
                                                        new Date().getTime() / 1e3
                                                    )),
                                                    a.default.userStorage.setDirty());
                                        })) :
                                    p(!1)) :
                                    (d ?
                                        r.Sounds.pauseMusic() :
                                        ((u = "视频耗尽"),
                                            a.default.platformCtrl.toast(
                                                n.locales.getText([
                                                    s.DatasManager.视频已用尽CN,
                                                    s.DatasManager.视频已用尽CN,
                                                    s.DatasManager.视频已用尽EN
                                                ])
                                            )),
                                        a.default.platformCtrl.rewardAdCtrl ?
                                        (a.default.platformCtrl.dd_clickVideoBtn(
                                                t,
                                                a.default.platformCtrl.rewardAdCtrl.adId,
                                                a.default.platformCtrl.rewardAdCtrl.可显示()
                                            ),
                                            i.scores.add("看视频加分", s.DatasManager.每看一次视频得分),
                                            a.default.platformCtrl.rewardAdCtrl.show(t, function(e) {
                                                a.default.platformCtrl.dd_closeVideo(
                                                        t,
                                                        a.default.platformCtrl.rewardAdCtrl.adId,
                                                        e
                                                    ),
                                                    p(e),
                                                    s.DatasManager.看视频CD > 0 &&
                                                    a.default.userStorage.获取玩家今日总次数("rewardShow") >=
                                                    s.DatasManager.每天看视频n次后开始CD &&
                                                    ((a.default.userStorage.看视频CDSec = Math.ceil(
                                                            new Date().getTime() / 1e3
                                                        )),
                                                        a.default.userStorage.setDirty());
                                            })) :
                                        p(!1))
                        } 
                        
                            // (a.default.platformCtrl.share(t, p), h());
                    }
                }
            }),

            (t.走视频 = function(t) {
                return (
                    console.log(11)
                    // !a.default.platformCtrl.显示分享 ||
                    // (a.default.platformCtrl.强制显示视频 ?
                    //     Adv_skd.default.instance.showVideo(()=>{
                    //         (console.log("f1"), !1)
                    //     },()=>{
                    //         (console.log("f2"), !1)
                    //     })
                    //     :
                    //     s.DatasManager.a ?
                    //     (console.log("a"), !0) :
                    //     (++a.default.userStorage.视频1分享0Index >= s.DatasManager.视频1分享0.length &&
                    //         (a.default.userStorage.视频1分享0Index = s.DatasManager.视频1分享0.length - 1),
                    //         s.DatasManager.视频1分享0[a.default.userStorage.视频1分享0Index] ?
                    //         t ?
                    //         (console.log("h s"), !0) :
                    //         (console.log("h " + this.剩余视频获取失败走分享次数), !(this.剩余视频获取失败走分享次数 > 0) || (this.剩余视频获取失败走分享次数--, !1)) :
                    //         (console.log(
                    //             s.DatasManager.视频1分享0,
                    //             a.default.userStorage.视频1分享0Index,
                    //             s.DatasManager.视频1分享0[a.default.userStorage.视频1分享0Index]
                    //         ), !1)))
                );
            }),
            t
        );
    })();
o.default = u;